set -xg PATH $HOME/.local/bin/ $HOME/work/bin/ /usr/local/bin $PATH
set -xg HOMEBREW_BOTTLE_DOMAIN https://mirrors.ustc.edu.cn/homebrew-bottles
#set -xg JAVA7_HOME (/usr/libexec/java_home -v 1.7)
#set -xg JAVA8_HOME (/usr/libexec/java_home -v 1.8)
#set -xg JAVA_HOME $JAVA8_HOME

# Homebrew
set -xg HOMEBREW_NO_AUTO_UPDATE true
set -xg HOMEBREW_BOTTLE_DOMAIN https://mirrors.ustc.edu.cn/homebrew-bottles/bottles #ckbrew
eval (bash /opt/homebrew/bin/brew shellenv) #ckbrew

#alias vim nvim
alias gradle8="gradle -Dorg.gradle.java.home=$JAVA8_HOME"
alias crypt="$HOME/git/scripts/py/tool/aes.py"
alias trash="$HOME/git/scripts/rm.sh"

alias gitpull='git fetch origin (git rev-parse --abbrev-ref HEAD); git rebase -v --autostash'
alias gitpush='git push origin (git rev-parse --abbrev-ref HEAD)'
alias gitpp='gitpull; gitpush'
alias gitpr='git push origin HEAD:refs/for/(git rev-parse --abbrev-ref HEAD)'
alias gitam='git add -A; git commit -m'
alias gitlog='git --no-pager log --graph --pretty=format:"%Cred%h%Creset %Cgreen[%ci]%Creset %C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset" --abbrev-commit'
alias gittag='git --no-pager log --tags --decorate --simplify-by-decoration --oneline'

# autojump
[ -f $HOME/.autojump/share/autojump/autojump.fish ]; and source $HOME/.autojump/share/autojump/autojump.fish

function fish_prompt
    echo ''
    set_color purple
    #echo -n -e '\342\224\214['
    echo -n -e '╭─['
    set_color green
    echo -n (pwd)
    set_color purple
    echo ]
    set_color purple
    #echo -n -e "\342\224\224["
    echo -n -e '╰─['
    set_color yellow
    echo -n (date '+%y/%m/%d_%H:%M:%S')
    set_color purple
    echo -n "] "
    set_color blue
    echo -n "$USER"
    if git branch > /dev/null 2>&1
        set_color yellow
        echo -n " ("(git rev-parse --abbrev-ref HEAD)")"
    end
    set_color 0FF
    echo -n ' >=> '
    set_color normal
end

function fullpath
    set dir (dirname $argv[1])
    set filename (basename $argv[1])
    set dirpath (cd $dir;pwd)
    echo $dirpath/$filename
end

function fish_greeting
    echo -E "Ready to work."
end

function len
    echo -n $argv[1] | wc -m
end

function pd
    set dirpath (pwd)
    set d (dirname $dirpath)
    set b (basename $d)
    while [ "$d" != "/" ] 
        if echo $b | grep -iqFE "^$argv[1]"
            cd $d
            break
        end
        set d (dirname $d)
        set b (basename $d)
    end
end

# 创建git远程分支
function gitb
    set branch_name $argv[1]
    echo ">> create local branch: $branch_name"
    git checkout -b $branch_name
    echo ">> create remote branch: $branch_name"
    git push -u origin HEAD:$branch_name
end

